package com.aiyige.model.request;

import com.aiyige.base.api.ApiManager;

import java.util.List;

import okhttp3.ResponseBody;
import retrofit2.Call;

/**
 * Created by usera on 2017/11/19.
 */

public class PublishImageRequest {
    public Long categoryId;
    public String title;
    public String detail;
    public String city;
    public Double lng;
    public Double lat;
    public List<Long> tagIds = null;
    public List<Image> images = null;

    private PublishImageRequest(Builder builder) {
        setCategoryId(builder.categoryId);
        setTitle(builder.title);
        setDetail(builder.detail);
        setCity(builder.city);
        setLng(builder.lng);
        setLat(builder.lat);
        setTagIds(builder.tagIds);
        setImages(builder.images);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public Long getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Long categoryId) {
        this.categoryId = categoryId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public Double getLng() {
        return lng;
    }

    public void setLng(Double lng) {
        this.lng = lng;
    }

    public Double getLat() {
        return lat;
    }

    public void setLat(Double lat) {
        this.lat = lat;
    }

    public List<Long> getTagIds() {
        return tagIds;
    }

    public void setTagIds(List<Long> tagIds) {
        this.tagIds = tagIds;
    }

    public List<Image> getImages() {
        return images;
    }

    public void setImages(List<Image> images) {
        this.images = images;
    }


    public static class Image {
        public String url;
        public String title;

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }
    }


    public static final class Builder {
        private Long categoryId;
        private String title;
        private String detail;
        private String city;
        private Double lng;
        private Double lat;
        private List<Long> tagIds;
        private List<Image> images;

        private Builder() {
        }

        public Builder categoryId(Long categoryId) {
            this.categoryId = categoryId;
            return this;
        }

        public Builder title(String title) {
            this.title = title;
            return this;
        }

        public Builder detail(String detail) {
            this.detail = detail;
            return this;
        }

        public Builder city(String city) {
            this.city = city;
            return this;
        }

        public Builder lng(Double lng) {
            this.lng = lng;
            return this;
        }

        public Builder lat(Double lat) {
            this.lat = lat;
            return this;
        }

        public Builder tagIds(List<Long> tagIds) {
            this.tagIds = tagIds;
            return this;
        }

        public Builder images(List<Image> images) {
            this.images = images;
            return this;
        }

        public Call<ResponseBody> build() {
            return ApiManager.getService().publishImage(new PublishImageRequest(this));
        }
    }
}
